import { useState } from 'react'

// 声明一个泛型
type User = {
  name: string
  age: number
}

function App() {
  // 传递泛型参数
  const [user, setUser] = useState<User | null | undefined>(null)

  const person = {
    name: 'jack',
    age: 18
  }

  // setUser只接受User类型
  setUser(person)

  return (
    // user是User类型
    <div>{user?.age}</div>
  )
}

export { App }
